#pragma once

#include "q_shared.h"

//----------------
//   ADMIN USERS
//----------------

typedef struct adminUser_s
{
   char         user[64];      //   User
   char         password[64];   //   Password
   unsigned int   privs;         //   32 privs
} adminUser_t;


//----------------
//   ADMIN COMMANDS
//----------------

typedef struct adminCommand_s
{//Each command has a privilege mask and function pointer. -1 priv-mask means anyone logged in can use it.
   char         *cmd;
   unsigned int   privs;
   void         (*func)(struct gentity_s *ent);
} adminCommand_t;


//----------------
//   ADMIN PRIVS
//----------------

#define PRIV_TELEPORT      (1<<0)      //   1         0x00001

#define PRIVSOK( ent, priv ) ( ent->client->pers.adminUser && (ent->client->pers.adminUser->privs & priv) )
#define AM_EXECUTE( ent, priv, func )                                       \
{                                                                  \
   if ( PRIVSOK( ent, priv ) )                                             \
   {                                                               \
      G_LogPrintf( "ADMIN :: %s executed by %s", cmd, ent->client->pers.netname );   \
      func( ent );                                                   \
      return qtrue;                                                   \
   }                                                               \
   else                                                            \
   {                                                               \
      goto NotAllowed;                                                \
   }                                                               \
}


void AM_ParseAdmins         ( void );
void AM_TM_ParseTelemarks   ( void );

#define AM_DECL( func ) void func ( struct gentity_s *ent )
AM_DECL( AM_Login            );
AM_DECL( AM_Logout            );
AM_DECL( AM_GunTeleport         );
#undef AM_DECL